{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Step 5: Train a Model\n",
    "\n",
    "Use the code below to run TensorBoard on the model in your pipeline."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensorboard_logdir: /home/tmy/airflow/tfx/pipelines/taxi/Trainer/output\n"
     ]
    }
   ],
   "source": [
    "from __future__ import print_function\n",
    "\n",
    "import os\n",
    "import webbrowser\n",
    "\n",
    "!pip install -q tensorboard\n",
    "\n",
    "pipeline_name = 'taxi'\n",
    "tensorboard_logdir = os.path.join(os.environ['HOME'], 'airflow/tfx/pipelines', pipeline_name, 'Trainer/output')\n",
    "print('tensorboard_logdir: {}'.format(tensorboard_logdir))\n",
    "os.environ['TENSORBOARD_LOGDIR'] = tensorboard_logdir"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Start TensorBoard\n",
    "\n",
    "Note: This cell continues to run until you interrupt the kernel.\n",
    "\n",
    "Start TensorBoard and look for the link to open a browser.  Click on that link, or copy and paste it into a new browser tab."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "W0706 16:28:02.065287 139746032703232 plugin_event_accumulator.py:294] Found more than one graph event per run, or there was a metagraph containing a graph_def, as well as one or more graph events.  Overwriting the graph with the newest event.\n",
      "W0706 16:28:02.066156 139746032703232 plugin_event_accumulator.py:302] Found more than one metagraph event per run. Overwriting the metagraph with the newest event.\n",
      "W0706 16:28:02.387992 139746032703232 plugin_event_accumulator.py:294] Found more than one graph event per run, or there was a metagraph containing a graph_def, as well as one or more graph events.  Overwriting the graph with the newest event.\n",
      "W0706 16:28:02.388882 139746032703232 plugin_event_accumulator.py:302] Found more than one metagraph event per run. Overwriting the metagraph with the newest event.\n",
      "TensorBoard 1.13.1 at http://tmy:6006 (Press CTRL+C to quit)\n",
      "WARNING:tensorflow:From /home/tmy/anaconda3/envs/tfx-env/lib/python3.6/site-packages/tensorboard/plugins/projector/projector_plugin.py:410: checkpoint_exists (from tensorflow.python.training.checkpoint_management) is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "Use standard file APIs to check for files with this prefix.\n",
      "W0706 16:28:08.429015 139745854191360 deprecation.py:323] From /home/tmy/anaconda3/envs/tfx-env/lib/python3.6/site-packages/tensorboard/plugins/projector/projector_plugin.py:410: checkpoint_exists (from tensorflow.python.training.checkpoint_management) is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "Use standard file APIs to check for files with this prefix.\n"
     ]
    }
   ],
   "source": [
    "!tensorboard --logdir=\"${TENSORBOARD_LOGDIR}\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
